home *** CD-ROM | disk | FTP | other *** search
- Program QueryTest;
- {from PC Magazine page 268, dated June 10, 1986 by Michael Johns
- of Nampa, Indiana. Function operates a menu selection system
- using the < and > keys to position the cursor on the menu. To use
- the UP and DOWN arrow keys, two read calls will be needed because of
- the extended key codes used.
- }
- var choice : integer;
-
- function Query (num, row, col, choice :integer): integer;
- var input : char;
- begin
- Gotoxy (col, row + choice - 1);
- write ('*');
- repeat
- repeat read (kbd,input);
- until ord (input) in [44,46,60,62,13];
- gotoxy (col, row + choice - 1);
- write(' ');
- if ord(input) in [44,60] then
- choice := choice - 1
- else if ord(input) in [46,62] then
- choice := choice + 1;
- choice := 1 + (choice + num - 1) mod num;
- gotoxy(col,row+choice-1);
- write('*');
- until ord(input) = 13;
- query := choice;
- end; { function Query (num, row, col, choice :integer) }
-
- BEGIN
- Clrscr;
- writeln('Menu (use <, >, and Enter)');
- writeln;
- writeln(' 1. Choice 1');
- writeln(' 2. Choice 2');
- writeln(' 3. Choice 3');
- writeln(' 4. Choice 4');
- choice := query (4,3,1,3);
- gotoxy(1,8);
- writeln('Choice is ',choice);
- END.